﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ISRecord.View.Services;
using ISRecord.View.ViewsModel;
using GalaSoft.MvvmLight.Messaging;
using ISRecord.Model;

namespace ISRecord.View.Views
{
    /// <summary>
    /// Interaction logic for Shell.xaml
    /// </summary>
    public partial class Shell : Window
    {
        ShellViewModel shellWorkspace = null;
        public Shell()
        {
            InitializeComponent();
            shellWorkspace = new ShellViewModel();
            base.DataContext = shellWorkspace;
            
            
        }
        private void ShowOutboxRecord(NotificationMessage msg)
        {
            if (msg.Notification == ViewsNames.OutboxRecordViewName)
            {
                OutboxViewWindow outboxWindow = new OutboxViewWindow();
                outboxWindow.Owner = this;
                outboxWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                outboxWindow.Show();
            }
        }

        private void ShellLoaded(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Register<NotificationMessage>(this, ShowOutboxRecord);
        }

        private void ShellClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Messenger.Default.Unregister<NotificationMessage>(this, ShowOutboxRecord);
        }

        
    }
}
